﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace miniCCR
{


    public class GObject
    {

        public uint _ID;
        public Dictionary<String, GComponent> _ComponentList = new Dictionary<String, GComponent>();


        public GObject()
        {
            _ID = _GenerateID++;
        }

        static uint _GenerateID = 1;
             

        public virtual void Init()
        {

        }

        //public T getComponent<T>()
        //{

        //    GComponent component;

        //    if (_ComponentList.TryGetValue(typeof(T).Name, out component))
        //    {
        //        return (T)(object)component;
        //    }

        //    return default(T);
        //}

        public GComponent AddComponent(GComponent newComp)
        {

            _ComponentList.Add(newComp.GetType().Name, newComp);
            newComp._Owner = this;
            return newComp;
        }

        public virtual void Post(Operation o)
        {
            o._ToID = _ID;
            ccrMain.I.Post(o);
            //foreach (var com in _ComponentList.Values)
            //{
            //    if( com._ComID  == o._ToComID)
            //        com.Post(o);
            //}
        }


        //public void Update()
        //{
        //    foreach (var com in _ComponentList.Values)
        //    {

        //    }
        //}


    }


}
